Skip to content

🐛 fix(ci): unfreeze openssl params via tracepoint - #1363

Open
sourabhpatel-sumo wants to merge 1 commit into
masterfrom
fix/openssl-require-hook
Open

sourabhpatel-sumo wants to merge 1 commit into
masterfrom
fix/openssl-require-hook

Conversation

@sourabhpatel-sumo

@sourabhpatel-sumo sourabhpatel-sumo commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Problem

Unit has failed on master since #1358 merged. Every rake task crashes at startup:

spec/openssl_unfreeze.rb:18:in 'OpenSSLUnfreezeOnRequire#require': NoMethodError
  from rspec-puppet-6.0.1/lib/rspec-puppet/monkey_patches.rb:399:in 'Kernel#require'

Cause

puppetlabs_spec_helper 9.0.1 (released 2026-11-17) requires rspec-puppet ~> 6.0. 9.0.0 required ~> 5.0. #1358's CI last ran on 2026-09-08, before that release, so it passed on rspec-puppet 5.0.0.

spec/openssl_unfreeze.rb unfreezes OpenSSL::SSL::SSLContext::DEFAULT_PARAMS so puppet 8's monkey_patches.rb can mutate it. It did that by hooking Kernel#require with Kernel.prepend. rspec-puppet 6 does alias old_require require in Kernel. Aliasing a method from a prepended module takes it out of the ancestor chain, so its super raises NoMethodError.

Both runs below use Ruby 3.4.13 in ruby:3.4.13, with the original file:

puppetlabs_spec_helper rspec-puppet Result
9.0.0 5.0.0 783 examples, 0 failures
9.0.1 6.0.1 NoMethodError at startup

Fix

Stop hooking require. The first version of this PR used an alias chain instead of prepend. That fixed Unit, but broke Acceptance Windows: Ruby's bundled_gems.rb replaces Kernel#require after our file loads, which skips an alias-chain hook. puppet module install then failed with FrozenError in monkey_patches.rb:56. The install step stayed green because PowerShell doesn't stop on a native exit code, and the tests failed with Resource type not found: Stdlib::Absolutepath.

Each kind of require hook breaks under one of these tools, so this version uses a TracePoint(:class) instead. It unfreezes DEFAULT_PARAMS when puppet reopens class OpenSSL::SSL::SSLContext, before the class body runs, whatever else has patched require. A guard stops a second load (Windows loads the file through both RUBYOPT -r and the Rakefile) from adding a second TracePoint.

Testing

Ran in ruby:3.4.13 (linux/amd64), with no lockfile and the same env as unit.yaml. Gems resolved to rspec-puppet 6.0.1 and openssl 4.0.2.

RUBYOPT="-r spec/openssl_unfreeze.rb" bundle exec puppet --version, which is the path that crashed on Windows:

Version Result
Alias chain (first push) FrozenError at monkey_patches.rb:56
TracePoint (this push) 8.10.0, also with the file loaded twice

Full Unit steps on the TracePoint version:

  • rake sensu_validate lint strings:generate reference: clean
  • rake parallel_spec: 4143 examples, 0 failures

Not fixed here

Acceptance full fails the same way on master and on this PR, so it isn't caused by this change. 06_postgresql_spec.rb fails because sensu_postgres_config sends pool_size: "20" as a string:

json: cannot unmarshal string into Go struct field PostgresConfig.pool_size of type int

That needs its own PR.

rspec-puppet 6 aliases Kernel#require and bundled_gems.rb redefines it, so any require hook breaks. Unfreeze when puppet reopens SSLContext instead.

Signed-off-by: Sourabh Patel <sourabh.patel.ctr@sumologic.com>
@sourabhpatel-sumo sourabhpatel-sumo changed the title 🐛 fix(ci): use alias chain for openssl require hook 🐛 fix(ci): unfreeze openssl params via tracepoint Nov 20, 2026
@sourabhpatel-sumo

Copy link
Copy Markdown
Member Author

The acceptance full failure is unrelated to this PR; it also fails on master. Cause: sensuctl >= 6.15.0 quotes integers in dump YAML output (sensu/sensu-go#5228). Tracked in #1368.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant